package m.meiweitech.com.mwsp.main

import android.view.View
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import com.hjq.toast.ToastUtils
import dagger.hilt.android.AndroidEntryPoint
import m.meiweitech.com.demo.R
import m.meiweitech.com.demo.databinding.FragmentMainBinding
import www.wen.com.common.lib.base.fragment.BaseLoadingFragment
import www.wen.com.common.lib.base.module.BaseApiViewModel
import www.wen.com.common.lib.base.module.BaseViewModel
import www.wen.com.common.lib.data.entities.builtIn.RequestBodyParameter


/**
 * @author WEN
 * @Description:核心读取页面
 * @date 2020//25 17:48
 */
@AndroidEntryPoint
class MainFragment : BaseLoadingFragment<FragmentMainBinding>() {

    private val mApiViewModel: BaseApiViewModel by viewModels()

    override val viewModel: BaseViewModel
        get() = mApiViewModel

    override fun getLayoutId(): Int = R.layout.fragment_main

    override fun lazyInitView() {

    }

    override fun onClick(v: View) {
        when (v.id) {
            R.id.textView -> {
                mApiViewModel.requestUniversal(lifecycleScope,
                    request = {
                        it.requestSignBasket(RequestBodyParameter())
                    },
                    isShowSuccessDialogTip = true,
                    isShowErrorDialogTip = true,
                    isShowErrorToastTip = false,
                    resultSuccessCall = { record ->
                        record!!
                        ToastUtils.show("请求成功")
                    })
            }
        }
    }

}



